# 定义集合
# 不重复、无序
aset = {23, 9, 78, 23, 45, 6, 23, 9, 78} # {6, 23, 9, 45, 78}
# print(aset)
# 不能放列表和字典、集合
bset = {5, 'hello', True, None, (4, 7, 9)}
# print(bset)
# 无法单独访问其中的元素
cset = {88, 46, 59, 93, 100}
# 判断是否含有元素
# print(100 in cset)
# print(cset, len(cset))
# for item in cset:
#     print(item)
# 新增
# cset.add(72)
# 删除
# cset.remove(100)
# print(cset)

"""
set1 = {1, 2, 3, 4}
set2 = {3, 4, 5, 6}
# 交集
print(set1 & set2, set1.intersection(set2))
# 并集
print(set1 | set2, set1.union(set2))
# 差集
print(set1 - set2, set1.difference(set2))
"""

names = ['小明', '小红', '小明', '小军', '小东', '小红']
# 将列表转为集合
s1 = set(names)  # {'小红', '小军', '小明', '小东'}
print(s1)
# 集合转为列表
print(list(s1))  # ['小红', '小明', '小东', '小军']




